import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<SetPasswordBySmsState> buildReducer() {
  return asReducer(
    <Object, Reducer<SetPasswordBySmsState>>{
      SetPasswordBySmsAction.updateLoading: _onLoadingAction,
      SetPasswordBySmsAction.updateRemain: _onSetRemainTextAction,
      SetPasswordBySmsAction.updateSmsId: _onSetSmsIdAction,
    },
  );
}

SetPasswordBySmsState _onLoadingAction(SetPasswordBySmsState state, Action action) {
  final SetPasswordBySmsState newState = state.clone();
  newState.isLoading = action.payload;
  return newState;
}
SetPasswordBySmsState _onSetRemainTextAction(SetPasswordBySmsState state, Action action) {
  final SetPasswordBySmsState newState = state.clone();
  newState.remainSeconds = action.payload;
  return newState;
}
SetPasswordBySmsState _onSetSmsIdAction(SetPasswordBySmsState state, Action action) {
  final SetPasswordBySmsState newState = state.clone();
  newState.smsId = action.payload;
  return newState;
}
